User.getPassword   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 3
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
1
import { Entity, Column, PrimaryGeneratedColumn, Index } from 'typeorm';
2
3
export enum UserRole {
4
  PHOTOGRAPHER = 'photographer',
5
  DIRECTOR = 'director'
6
}
7
8
@Entity()
9
export class User {
10
  @PrimaryGeneratedColumn('uuid')
11
  private id: string;
12
13
  @Column({ type: 'varchar', nullable: false })
14
  private firstName: string;
15
16
  @Column({ type: 'varchar', nullable: false })
17
  private lastName: string;
18
19
  @Column({ type: 'varchar', unique: true, nullable: false })
20
  private email: string;
21
22
  @Index('api-token')
23
  @Column({ type: 'varchar', nullable: true })
24
  private apiToken: string;
25
26
  @Column({ type: 'varchar', nullable: false })
27
  private password: string;
28
29
  @Column('enum', { enum: UserRole, nullable: false })
30
  private role: UserRole;
31
32
  constructor(
33
    firstName: string,
34
    lastName: string,
35
    email: string,
36
    apiToken: string,
37
    password: string,
38
    role: UserRole
39
  ) {
40
    this.firstName = firstName;
41
    this.lastName = lastName;
42
    this.email = email;
43
    this.apiToken = apiToken;
44
    this.password = password;
45
    this.role = role;
46
  }
47
48
  public getId(): string {
49
    return this.id;
50
  }
51
52
  public getFirstName(): string {
53
    return this.firstName;
54
  }
55
56
  public getLastName(): string {
57
    return this.lastName;
58
  }
59
60
  public getEmail(): string {
61
    return this.email;
62
  }
63
64
  public getApiToken(): string {
65
    return this.apiToken;
66
  }
67
68
  public getPassword(): string {
69
    return this.password;
70
  }
71
72
  public getRole(): UserRole
73
  {
74
    return this.role;
75
  }
76
77
  public update(firstName: string, lastName: string, email: string): void {
78
    this.firstName = firstName;
79
    this.lastName = lastName;
80
    this.email = email;
81
  }
82
83
  public updatePassword(password: string): void {
84
    this.password = password;
85
  }
86
}
87